#import time
#import dailyspents.util as util
#import os
#from os.path import join
<html>

#include join(util.HTMLPATH, 'common', 'head.html')

<body>
	<div id="site">
		#include join(util.HTMLPATH, 'common', 'top.html')
		#include join(util.HTMLPATH, 'common', 'menu.html')
		<div id="content">
		  <!-------------------- LEFT SIDE ------------------------->
		  <div id="left">
		    <div class="tl"><div class="tr">
			    edit spent
			</div></div>
			
			#include join(util.HTMLPATH, 'common', 'errorMessages.html')
			
			#import cherrypy
            <!---------------------- NEW SPENT FORM -------------------------->
            <div class="newSpentForm">
            	<form name="newForm" action="/spent/edit" method="POST">
            		<input type="hidden" name="id" value="$spent.id"/>
            		<table>
                        <tr>
                            <td><label for"localId">local</label></td>
                            <td>
                                <select name="localId" onchange="isNewLabel(this);">
                                    <option selected="selected">Select...
                                    #for local in $cherrypy.session['user'].locals:
                                        #if $spent.local != None and $spent.local.id == $local.id:
                                            <option value="$local.id" selected="selected"> $local.name
                                        #else:
                                            <option value="$local.id"> $local.name
                                        #end if
                                        
                                    #end for
                                    <option value="new">New local...
                                </select>
                            </td>
                        </tr>
            		<tr>
            		<td><label for="categoryId">category</label></td>
            		<td>
            		<select name="categoryId" onchange="isNewCategory(this);">
            			<option value="">Select...</option>
            			#for cat in $cherrypy.session['user'].categories:
            				#if $spent.category != None and $spent.category.id == cat.id:
            					<option value="$cat.id" selected="selected">$cat.name</option>
            				#else:
            					<option value="$cat.id">$cat.name</option>
            				#end if
            			#end for
                                <option value="new">New category...
            		</select>
            		</td>
            		</tr>
            		<tr>
            		<td><label for="paymentId">payment mode</label></td>
            		<td>
            		<select name="paymentId" onchange="isNewPayment(this);">
            			<option value="">Select...</option>
            			#for payment in $cherrypy.session['user'].payments:
            				#if $spent.payment != None and $spent.payment.id == payment.id:
            					<option selected="selected" value="$payment.id">$payment.name</option>
            				#else:
            					<option value="$payment.id">$payment.name</option>
            				#end if
            			#end for
                                <option value="new">New payment...
            		</select>
            		</td>
            		</tr>
            		<tr>
            		<td><label for="date">date</label></td>
            		<td>
            		<INPUT TYPE="text" NAME="date" VALUE="$spent.date" SIZE=8 readonly="readonly">
            		<a href="javascript:cal1.popup();"><img src="/static/images/x-office-calendar.png" 
            			width="16" height="16" border="0" alt="Click Here to Pick up the date"></a>
            		</td>
            		</tr>
            		<tr>
            		<td><label for="value">value</label></td>
            		<td><input type="text" name="value" size="5" value="$spent.value"/></td>
            		</tr>
            		<tr>
            		<td><label for="description">Description</label></td>
            		<td><textarea name="description" cols="30" rows="5"/>$spent.description</textarea></td>
            		</tr>
            		</table>
            		<table>
            		<hr/>
            		<tr>
            		<td><input type="submit" value="Save"/></td>
            		<td>
            		<input type="reset" value="clear"/>
            		</td>
            		</tr>
            		</table>
            	</form>
            	<script>
            		var cal1 = new calendar3(document.forms['newForm'].elements['date']);
            	</script>
            </div>
            <!-- END OF NEW SPENT FORM -->
		  </div>
		  <!-- END OF LEFTSIDE -->
		  <!-- RIGHTSIDE -->
		  <div id="right">
				
			  	#include join(util.HTMLPATH, 'common', 'categories.html')
				#include join(util.HTMLPATH, 'common', 'locals.html')
				#include join(util.HTMLPATH, 'common', 'payments.html')
				
		  </div>
		</div>
		#include join(util.HTMLPATH, 'common', 'bottom.html')
	</div>
</body>

</html>
